<?php

class integral_goodsApp extends MallbaseApp {

    var $_user_id;
    var $_integral_goods_mod;

    function __construct() {
        $this->integral_goodsApp();
    }

    function integral_goodsApp() {
        parent::__construct();
        $this->_user_id = $this->visitor->get('user_id');
        $this->_integral_goods_mod = & m('integral_goods');
    }

    function index() {
        //判断用户是否登录 登录则获得用户相关信息
        if ($this->_user_id) {
            $user_mod = & m('member');
            $user = $user_mod->get_info($this->_user_id);
            $user['ugrade'] = $user_mod->get_grade_info($user['user_id']);
            $user['portrait'] = portrait($user['user_id'], $info['portrait'], 'middle');
            $this->assign('user', $user);
        }
        
        $conditions = "";
        $page = $this->_get_page(16);   //获取分页信息
        //获取当前积分兑换的产品
        $integral_goods_list = $this->_integral_goods_mod->find(array(
            'conditions' => '1=1 ' . $conditions,
            'limit' => $page['limit'],
            'order' => "add_time desc",
            'count' => true   //允许统计
        ));
        $page['item_count'] = $this->_integral_goods_mod->getCount();   //获取统计数据
        $this->_format_page($page);
        $this->assign('page_info', $page);
        $this->assign('integral_goods_list', $integral_goods_list);
        $this->display('integral_goods.index.html');
    }
}
